package intelligentcity.gui;

import intelligentcity.model.streets.HorizontalOneWayStreet;
import intelligentcity.model.streets.VerticalOneWayStreet;
import intelligentcity.model.traffic.Car;
import intelligentcity.model.traffic.Traffic;

import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;

public class TrafficDrawer {

    public static void drawTraffic(Graphics2D g2d, Traffic traffic) {
        for (Integer i : traffic.getCars().keySet()) {
            drawCar(g2d, traffic.getCars().get(i));
        }

    }

    public static void drawCar(Graphics2D g2d, Car car) {
        int x = car.getPoint().getX();
        int y = car.getPoint().getY();
        if (car.getCurrentOWS() instanceof HorizontalOneWayStreet) {
            y -= 5;
        }
        if (car.getCurrentOWS() instanceof VerticalOneWayStreet) {
            x -= 5;
        }
        g2d.fill(new Ellipse2D.Double(x, y, 10, 10));
    }

}
